package org.hairball;

import org.hairball.cli.CommandLineParseException;
import org.hairball.util.FileUtils;

import java.io.IOException;

public class Hairball {

    public static void main(String[] args) throws IOException {
        try {
            Configuration configuration = new ConfigReader().read(args);
            Format format = configuration.getFormat();
            String diagram = format.createDiagram(configuration);
            FileUtils.writeFile(configuration.getOutputFile(), diagram);
        } catch (CommandLineParseException e) {
            System.err.println("Error in arguments:\n\t" + e.getMessage() + "\n");
            System.err.println("Required Arguments:\n" + e.getProperUsage());
        }
    }
}
